package adventure_game;

import java.util.HashMap;

/**
 * Checks if the input words are valid.
 * @author Frank, Morten B, Ronni
 */
public class CommandWords
{
    private HashMap<String, CommandWord> validCommands;
    
    /**
    * If valid word, this starts command.
    */
    public CommandWords()
    {
        validCommands = new HashMap<String, CommandWord>();
        for (CommandWord command : CommandWord.values())
        {
            if (command != CommandWord.UNKNOWN)
            {
                validCommands.put(command.toString(), command);
            }
        }
    }

    public CommandWord getCommandWord(String commandWord)
    {
        CommandWord command = validCommands.get(commandWord);
        if (command != null)
        {
            return command;
        }
        else
        {
            return CommandWord.UNKNOWN;
        }
    }

    public boolean isCommand(String aString)
    {
        return validCommands.containsKey(aString);
    }

    /**
    * udskriver ordet
    */
    public void showAll()
    {
        for (String command : validCommands.keySet())
        {
            System.out.print(command + "  ");
        }
        System.out.println();
    }
}
